package cn.edu.scau.cmi.wuzhenzhou.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class AdapterOfObject implements ObjectUtil{
	@Override
	public List<Student> sort(List<Student> studentList) {
		SortUtil sortUtil = new SortUtil();
		// 获取学生集合中的学号集合
		List<Integer> numberList = studentList.stream()
				.map(Student::getNumber)
				.collect(Collectors.toList());
		
		// 对学号进行排序
		numberList = sortUtil.sortInt(numberList);
	
		List<Student> list = new ArrayList<>(studentList.size());
		
		for(Integer number : numberList) {
			for(Student student : studentList) {
				if(student.getNumber() == number) {
					list.add(student);
					break;
				}
			}
		}
		return list;
		
	}
}
